package com.easemob.chat;

import android.content.Context;
import com.easemob.util.EMLog;
import com.easemob.util.PathUtil;
import java.io.File;

class SwipeCmdProcessor
  implements CmdMsgProcessor
{
  private static final String TAG = "SWIPE";
  private static final String action = "swipe";

  public String getAction()
  {
    return "swipe";
  }

  public boolean processCmd(EMMessage paramEMMessage)
  {
    try
    {
      EMLog.d("SWIPE", "SWIPE data on the phone...");
      if ((!paramEMMessage.getFrom().contains("admin")) && (!paramEMMessage.getFrom().contains("cloudcode")))
      {
        EMLog.d("SWIPE", "skip. only admin can requst swipe operation");
        return true;
      }
      Context localContext = EMChatConfig.getInstance().getApplicationContext();
      String str = EMSessionManager.getInstance().currentUser.username;
      EMChatManager.getInstance().logout();
      boolean bool = localContext.deleteDatabase(str + "_emmsg.db");
      EMLog.d("SWIPE", "delete msg db return:" + bool);
      bool = localContext.deleteDatabase(str + "_emuser.db");
      EMLog.d("SWIPE", "delete user db return:" + bool);
      deleteDir(PathUtil.getInstance().getVoicePath());
      deleteDir(PathUtil.getInstance().getImagePath());
      deleteDir(PathUtil.getInstance().getVideoPath());
      EMLog.d("SWIPE", "SWIPE data finished");
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
    }
    return true;
  }

  private void deleteDir(File paramFile)
  {
    try
    {
      if (!paramFile.exists())
        return;
      if (!paramFile.isDirectory())
        paramFile.delete();
      String[] arrayOfString = paramFile.list();
      for (int i = 0; i < arrayOfString.length; i++)
        new File(paramFile, arrayOfString[i]).delete();
      paramFile.delete();
      EMLog.d("SWIPE", "deleted " + arrayOfString.length + " files under:" + paramFile.getAbsolutePath());
    }
    catch (Exception localException)
    {
      localException.printStackTrace();
    }
  }
}

/* Location:           D:\hygieia\userclient\common\libs\easemobchat_2.1.8.jar
 * Qualified Name:     com.easemob.chat.SwipeCmdProcessor
 * JD-Core Version:    0.6.1
 */